package com.example.nettyexp.nioc2;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel;
import java.nio.charset.Charset;

/**
 * @Description : TODO
 * @Author : ZYX
 * @Date : 2022/9/9 14:06
 * @Version : 1.0
 **/
public class Client {

    public static void main(String[] args) throws IOException {
        SocketChannel open = SocketChannel.open();
        open.connect(new InetSocketAddress("localhost",8080));
//        open.write(Charset.defaultCharset().encode("hallo"));
        SocketAddress localAddress = open.getLocalAddress();
        // 模拟黏包 半包
        open.write(Charset.defaultCharset().encode("012\n3456789abcdefgh"));
        open.write(Charset.defaultCharset().encode("0123456789abcdefgh4444\n"));
        open.close();
    }

}
